package huu.phong.youtube;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

public class SuggestRenderer implements ListCellRenderer {
	
	Color odd = new Color(238, 238, 238);
	Color even = Color.WHITE;
	Color selected = new Color(51, 153, 255);
	JLabel text;
	
	public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
		text = new JLabel(value.toString());
		text.setOpaque(true);
		text.setFont(list.getFont());
		if (index % 2 == 0){
			text.setBackground(even);
		}else{
			text.setBackground(odd);
		}
		if (isSelected){
			text.setBackground(selected);
			text.setForeground(Color.WHITE);
		}
		return text;
	}

}
